# ar平台 题库管理
import unittest
from time import sleep

from Common.base_test import BaseTestClass
from PageObjects.login.login_page import LoginPage
from PageObjects.AR.ar_home import QuestionBankManagementPage
from TestDatas.login_datas import success_data
from TestDatas.CommDatas import web_login_url
from TestDatas.ArDatas.ar_question_bank_management_datas import *


class ArQuestBankManage(BaseTestClass):
    """AR平台题库管理"""
    def test_0_1_go_to_ar_question_bank_management(self):
        """OA登录并跳转AR"""
        self.driver.get(web_login_url)
        self.lp = LoginPage(self.driver)
        # 步骤：登录页面-登录操作
        self.lp.login(success_data["user"], success_data["pwd"])
        sleep(3)
        self.assertTrue(self.lp.assert_welcome())
        self.lp.go_ar()
        sleep(10)

    def test_0_2_create_scratch(self):
        """题目管理-新增题目-scratch操作题"""
        self.lp = LoginPage(self.driver)
        sleep(5)
        self.lp.switch_window("学术研发")
        self.qbmp = QuestionBankManagementPage(self.driver)
        self.qbmp.subject_create_scratch(qbm_subject_module_params["nb2_loc"], qbm_subject_module_params["nb2_name"])
        self.driver.close()
        self.lp.switch_window("统一登录")

    def test_0_3_create_python(self):
        """题目管理-新增题目-python操作题"""
        self.lp = LoginPage(self.driver)
        self.lp.go_ar()
        sleep(10)
        self.lp.switch_window("学术研发")
        self.qbmp = QuestionBankManagementPage(self.driver)
        self.qbmp.subject_create_scratch(qbm_subject_module_params["nb2_loc"], qbm_subject_module_params["nb2_name"],
                                         question_type="python")
        self.driver.close()
        self.lp.switch_window("统一登录")

    def test_0_4_subject_lst(self):
        """题目管理列表"""
        self.lp = LoginPage(self.driver)
        self.lp.go_ar()
        sleep(10)
        self.lp.switch_window("学术研发")
        self.qbmp = QuestionBankManagementPage(self.driver)
        self.qbmp.subject_lst(qbm_subject_module_params["nb2_loc"], qbm_subject_module_params["nb2_name"])
        self.driver.close()
        self.lp.switch_window("统一登录")

    def test_0_5_create_examination_paper(self):
        """试卷管理-新增试卷"""
        self.lp = LoginPage(self.driver)
        self.lp.go_ar()
        sleep(10)
        self.lp.switch_window("学术研发")
        self.qbmp = QuestionBankManagementPage(self.driver)
        self.qbmp.change_module_page(nb2_loc=qbm_examination_paper_module_params["nb2_loc"],
                                     nb2_name=qbm_examination_paper_module_params["nb2_name"])
        self.qbmp.create_examination_paper()
        self.driver.close()
        self.lp.switch_window("统一登录")

    def test_0_6_examination_paper_lst(self):
        """试卷管理-列表"""
        self.lp = LoginPage(self.driver)
        self.lp.go_ar()
        sleep(10)
        self.qbmp = QuestionBankManagementPage(self.driver)
        self.qbmp.examination_paper_lst()

